<template>
	<div>
		<!--商品列表--> <!-- :class="{delMagin: !flag}"-->
        <div class="aui-content choose_list"  @click="goInfomation">
            <ul class="aui-list aui-media-list">
                <li class="aui-list-item iscroll_list">
                    <div id="co_orderGoods" class="aui-media-list-item-inner scroller_list">
						<div class="aui-list-item-media" v-for="(item,index) in cartList" :key="index" v-if="checkedCartList && checkedCartList.length">
							<!--<img :src="goodsImg(item) || 'static/image/demo1.png'" style="height: 100%;"/>--> 
							<img v-lazy="goodsImg(item)  || 'static/image/demo2.png'" style="height: 100%;"/> 
							<em style="background:#EF5423;opacity: 0.6;">x{{item.goodsType == 7?'1':item.goodsNum}}</em>
						</div>	
						<!--为了让用户能看到最后一个盒子-->
						<div class="aui-list-item-media" >
							
						</div>	
                    </div>
                </li>
            </ul>
            <div class="aui-list-item-arrow statistics">
               <div style="margin-top: 0.4rem;">
               		<p>共<span id="co_totalPiece">{{num}}</span>件</p>
                	<p id="co_totalPackage">{{allFlag?'2个包裹':'1个包裹'}}</p>
               </div>
            </div>
            <!--<div class="aui-list-item-arrow01 server_show" v-if="sendNameArr && sendNameArr.length != 0" style="background-color: #fff2f2;padding: 0.2rem 0.5rem;">
		        <div style="margin-left: 15;text-align: left;" class="aui-list-item-arrow_2">
					<h4>[赠品]</h4>
					<dl>
						<dd v-for="item in sendNameArr">-->
							<!--<font>{{item}}</font>-->  <!--赠品名称-->
							<!--<span>¥9.8×1</span>-->
						<!--</dd>
					</dl>
				</div>
			</div>-->
        </div>
       
        <!--商品列表 end-->
	</div>
</template>

<script>
	import {mapGetters,mapMutations} from 'vuex';
	export default {
		props: {
           checkedCartList:{
           		type:Array,
           		default:function(){
           			let arr = [];
           			return arr
           		}
           },
           flag:{
	           	type:Boolean,
	           	default:function(){
	           		return true
	           	}
           },
           checkedCartListNormal: {
           		type:Array,
           		default:function(){
           			let arr = [];
           			return arr
           		}
           },
           checkedCartListBig: {
           		type:Array,
           		default:function(){
           			let arr = [];
           			return arr
           		}
           }
//         delFlag:{
//         		type:Number,
//         		default:0
//         }
        },
        computed:{
        	...mapGetters('cjy', [
				"selectGiftList", "selectLadderList", "buyMoreData"
			]),
			...mapGetters('zx', [
				"getGiftSendArr"
			]),
        },
        watch:{
        	checkedCartList(newVal,oldVal){
                console.log(newVal,oldVal,'购物车数据来了********')
                this.cartList = this.checkedCartList;
                this.getGoodsNum();
            }
        },
        data () {
            return {
               cartList:[],
               num:null,
               money:null,
               allFlag:false
            }
        },
        methods: {
        	goInfomation(){
        		var obj = {};
        		obj.flag = this.allFlag;
        		if(this.flag){
        			obj.type = "常规配送";
        		}else{
        			obj.type = "大件配送";
        		}
        		var arr = [];
        		arr.push(this.checkedCartListNormal);
        		arr.push(this.checkedCartListBig);
        		this.$router.push({path:'orderInformation',query:{arr:arr,obj:obj}});
        	},
        	goodsImg(goodsItemData) {
	            if (goodsItemData && goodsItemData.urllist) {
	                if(goodsItemData.urllist.length) {
	                	for(let i = 0 ; i < goodsItemData.urllist.length; i++){
	                		if(goodsItemData.urllist[i].Imgurltype == 1){
	                			return goodsItemData.urllist[i].imgurl || "static/image/demo1.png";
	                		}
	                	}
	                } else {
	                    return "static/image/demo1.png";
	                }
	            } else {
	                return "static/image/demo1.png";
	            }
	        },
	        getGoodsNum() {
	        	if(this.cartList.length != 0){
	        		for(let i = 0 ; i < this.cartList.length; i++){
//						6 称重按只   7 称重散装
		            	if(this.cartList[i].goodsType == 7){
							this.num += 1
						}else{
							this.num += this.cartList[i].goodsNum;
						}
		            }
	        	}
	           
	        },
	        eventListen(){
	        	console.log(22)
	        	var co_orderGoods = document.getElementById('co_orderGoods');
	        	co_orderGoods.addEventListener('scroll', function(e) {
	        		console.log(co_orderGoods.scrollLeft )
//	        		console.log(screen.width,'screen')	
//	        		if(screen.width == co_orderGoods.scrollLeft){
	        			console.log("拉到底了")
//	        		}
	        	})
	        }
	        
        },
        mounted(){
        	this.cartList = this.checkedCartList;
			if(this.checkedCartListNormal.length && this.checkedCartListBig.length){
				this.allFlag = true;
			}
        },
        created(){
        	
        	
        	// console.log(this.cartList,'this.cartList传过来的数据');
        }
	}
</script>

<style scoped="scoped">
	.settle_accounts {
	    height: 3rem;
	    background: rgba(255, 255, 255, 0.9);
	    overflow: hidden;
	    position: fixed;
	    width: 100%;
	    left: 0;
	    bottom: -1px;
	    display: table;
	    border-top: 1px solid #eaeaea;
	    z-index: 1;
	}
	.scroller_list {
        overflow-y: auto;
    }
   	.iscroll_list {
	    height: 5.5rem !important;
	}
	.delMagin{
		margin-bottom: 0;
	}
	.scroller_list{
		position: relative;
	}
	.server_show::after{
		border: 0px solid;
	}
</style>